<h1>文章列表</h1>

<div class="alert alert-success">
  根据置顶时间对文章进行排序。
</div>

<div class="row" style='margin-bottom: 5px;'>
  <%= form_tag admin_articles_path, method: :get do %>
    <div class="col-lg-8">
    </div>
    <div class="col-lg-3">
      <div class="input-group">
        <%= text_field_tag :title, params[:title], class: "form-control", placeholder: "文章标题" %>
        <span class="input-group-btn">
          <%= submit_tag "搜索", class: "btn btn-default" %>
        </span>
      </div>
    </div>
  <% end %>
</div>

<table class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
      <th>标题</th>
      <th>类别</th>
      <th>tags</th>
      <th>置顶</th>
      <!--<th>置顶时间</th>-->
      <th>相关产品</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @articles.each do |article| %>
      <tr>
        <td><%= article.title %></td>
        <td><%= article.category %></td>
        <td><%= article.tags %></td>
        <td><%= article.top %></td>
        <!--<td><%= article.top_at.to_s %></td>-->
        <td><%= article.products.map{|product| link_to product.title, admin_product_path(product) }.join("<br/>").html_safe %></td>
        <td><%= link_to 'Show', [:admin, article] %></td>
        <td><%= link_to 'Edit', edit_admin_article_path(article) %></td>
        <td><%= link_to 'Destroy', [:admin, article], method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<%= paginate @articles %>

<br>

<%= link_to '新建文章', new_admin_article_path %>
